<template>
	<view class="tream">
		<view class="tabs flex-around">
			<view class="flex-center" :class="{active:tabIndex == 0}" @click="changeTab(0)">大区</view>
			<view class="flex-center" :class="{active:tabIndex == 1}" @click="changeTab(1)">小区</view>
		</view>
		<view class="date flex">
			<view class="label">月份</view>
			<picker mode="date" fields="month" :value="date" @change="bindDateChange">
				<view class="uni-input flex">
					{{date}}
					<image src="/static/arrow-w.png" mode="widthFix"></image>
				</view>
			</picker>
		</view>
		<view class="content">
			<view class="total">小区总业绩：<text>0</text></view>
			<view class="list-box">
				<block v-for="(item,index) in 3" :key="index">
					<view class="list flex-between">
						<view class="left flex">
							<image src="" v-if="false" mode="aspectFill" class="avatar"></image>
							<view class="avatar flex-center" v-else>
								<image src="/static/tab3.png" mode="widthFix"></image>
							</view>
							
							<view class="user-msg">
								<view class="name flex">
									<text>老侯</text>
									<view class="label">初始</view>
								</view>
								<view class="code">
									会员编号：123466
								</view>
							</view>
						</view>
						<view class="right">
							<view class="p">团队业绩</view>
							<view class="h4">0</view>
						</view>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				tabIndex: 0,
				date: currentDate
			};
		},
		onLoad() {

		},
		methods: {
			changeTab(index) {
				this.tabIndex = index;
			},
			// 选择日期
			bindDateChange(e) {
				this.date = e.target.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style lang="less">
	@color: #106ee8;

	.tream {
		.tabs {
			align-items: flex-start;
			height: 80rpx;
			background: #171a2d;

			view {
				width: 150rpx;
				height: 78rpx;
				color: white;

				&.active {
					color: @color;
					border-bottom: 2rpx solid @color;
				}
			}
		}
		.date{
			padding: 0 30rpx;
			.label{
				color:white;
				font-size: 30rpx;
			}
			.uni-input{
				width: 600rpx;
				justify-content: flex-end;
				color:rgba(255,255,255,.6);
				font-size: 26rpx;
				line-height: 80rpx;
				image{
					width: 28rpx;
					height:auto;
					margin-left: 15rpx;
				}
			}
		}
		.content{
			padding: 0 30rpx;
			.total{
				font-size: 32rpx;
				color:#aaa;
				text{
					color:white;
				}
			}
			.list-box{
				margin-top: 30rpx;
				.list{
					background: rgba(23,26,45,.6);
					padding: 20rpx;
					border-radius: 10rpx;
					margin-bottom: 30rpx;
					.left{
						.avatar{
							width: 90rpx;
							height:90rpx;
							border-radius: 50%;
							background: #eee;
							margin-right: 20rpx;
							image{
								width: 50rpx;
								height:auto;
							}
						}
						.user-msg{
							.name{
								font-size: 30rpx;
								color:white;
								margin-bottom: 10rpx;
								.label{
									padding: 3rpx 20rpx;
									border-radius: 20rpx;
									font-size: 24rpx;
									background: #007AFF;
									margin-left: 15rpx;
									transform: scale(.8);
								}
							}
							.code{
								color:#3f81c1;
								font-size: 24rpx;
							}
						}
					}
					.right{
						.p{
							font-size: 24rpx;
							color:#3f81c1;
							text-align: right;
							margin-bottom: 10rpx;
						}
						.h4{
							font-size: 28rpx;
							color:white;
							text-align: right;
						}
					}
				}
			}
		}
	}
</style>
